package com.happyfamily.springboot.crowdsourcingplatform.dao.guo;

import com.happyfamily.springboot.crowdsourcingplatform.model.FriendshipLink;
import com.happyfamily.springboot.crowdsourcingplatform.model.Need;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;

@Mapper
public interface FriendShipDao
{

	List<FriendshipLink> getFriendList(RowBounds rowBounds, @Param("ftitle") String ftitle);

	int  getFriendListCount(String ftitle);

	/**
	 *根据链接状态获取链接集合
	 * @param fstatus 链接状态
	 * @return
	 */
	@Select("SELECT * FROM friendship_link WHERE fstatus=#{fstatus} order by tips1 desc")
	List<FriendshipLink> getFriendListFront(String fstatus);

	/**
	 * 友情链接表插入数据
	 * @param furl 网页路径
	 * @param fimage 图片路径
	 * @param ftitle 链接标题
	 * @param fstatus 友情链接状态
	 * @return
	 */
	@Insert("INSERT INTO friendship_link (furl,fimage,ftitle,fstatus) VALUES(#{furl},#{fimage},#{ftitle},#{fstatus})")
	int addFriendLink(String furl,String fimage,String ftitle,String fstatus);

	/**
	 * 根据友情id修改友情链接状态
	 * @param fstatus 友情状态
	 * @param fid   友情id
	 * @return
	 */
	@Update("UPDATE friendship_link SET fstatus=#{fstatus} WHERE fid=#{fid}")
	int changeTypeBuFid(String fstatus,Long fid);

	/**
	 * 根据友情id删除友情对象
	 * @param fid 友情id
	 * @return
	 */
	@Delete("DELETE FROM friendship_link WHERE fid=#{fid}")
	int changeTypeBuFidDelete(Long fid);

	/**
	 * 根据友情id查询友情对象
	 * @param fid  友情id
	 * @return
	 */
	@Select("SELECT * FROM friendship_link WHERE fid=#{fid}")
	FriendshipLink getInfoFriendLink(Long fid);

	/**
	 * 根据友情链接id更改友情链接得标题和网址路径
	 * @param ftitle 友情链接标题
	 * @param furl  友情链接网址
	 * @param fid  友情链接id
	 * @return
	 */
	@Update("UPDATE friendship_link SET ftitle=#{ftitle},furl=#{furl} WHERE fid=#{fid}")
	int changeTypeBuFidUpdate(String ftitle,String furl,Long fid);



}
